]> git.r.bdr.sh - rbdr/super-polarity/blame_incremental - Super Polarity/SuperPolarity.cs
I think bullets come out now.
[rbdr/super-polarity] / Super Polarity / SuperPolarity.cs
... / ...
CommitLineData
1#region Using Statements
2using System;
3using System.Collections.Generic;
4using Microsoft.Xna.Framework;
5using Microsoft.Xna.Framework.Content;
6using Microsoft.Xna.Framework.Graphics;
7using Microsoft.Xna.Framework.Input;
8using Microsoft.Xna.Framework.Storage;
9using Microsoft.Xna.Framework.GamerServices;
10using SuperPolarity;
11#endregion
12
13namespace SuperPolarity
14{
15 /// <summary>
16 /// This is the main type for your game
17 /// </summary>
18 public class SuperPolarity : Game
19 {
20 public static GraphicsDeviceManager graphics;
21 SpriteBatch spriteBatch;
22
23 public static int OutlierBounds;
24
25 public SuperPolarity()
26 : base()
27 {
28 SuperPolarity.graphics = new GraphicsDeviceManager(this);
29 SuperPolarity.graphics.PreferMultiSampling = true;
30 Content.RootDirectory = "Content";
31 ActorFactory.SetGame(this);
32 ParticleEffectFactory.SetGame(this);
33 ActorManager.SetGame(this);
34 }
35
36 /// <summary>
37 /// Allows the game to perform any initialization it needs to before starting to run.
38 /// This is where it can query for any required services and load any non-graphic
39 /// related content. Calling base.Initialize will enumerate through any components
40 /// and initialize them as well.
41 /// </summary>
42 protected override void Initialize()
43 {
44 base.Initialize();
45
46 OutlierBounds = 100;
47
48 InputController.RegisterEventForButton("changePolarity", Buttons.A);
49 InputController.RegisterEventForKey("changePolarity", Keys.Z);
50
51 InputController.RegisterEventForButton("shoot", Buttons.X);
52 InputController.RegisterEventForKey("shoot", Keys.X);
53 }
54
55 /// <summary>
56 /// LoadContent will be called once per game and is the place to load
57 /// all of your content.
58 /// </summary>
59 protected override void LoadContent()
60 {
61 // Create a new SpriteBatch, which can be used to draw textures.
62 spriteBatch = new SpriteBatch(GraphicsDevice);
63
64 Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
65
66 Renderer.CheckIn(ActorFactory.CreateMainShip(playerPosition));
67 Renderer.CheckIn(ActorFactory.CreateShip(Ship.Polarity.Positive, new Vector2(200, 200)));
68 Renderer.CheckIn(ActorFactory.CreateShip(Ship.Polarity.Negative, new Vector2(400, 200)));
69 }
70
71 /// <summary>
72 /// UnloadContent will be called once per game and is the place to unload
73 /// all content.
74 /// </summary>
75 protected override void UnloadContent()
76 {
77 // TODO: Unload any non ContentManager content here
78 }
79
80 /// <summary>
81 /// Allows the game to run logic such as updating the world,
82 /// checking for collisions, gathering input, and playing audio.
83 /// </summary>
84 /// <param name="gameTime">Provides a snapshot of timing values.</param>
85 protected override void Update(GameTime gameTime)
86 {
87 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
88 Exit();
89
90 // TODO: Add your update logic here
91
92 InputController.UpdateInput();
93 ActorManager.Update(gameTime);
94
95 base.Update(gameTime);
96 }
97
98 /// <summary>
99 /// This is called when the game should draw itself.
100 /// </summary>
101 /// <param name="gameTime">Provides a snapshot of timing values.</param>
102 protected override void Draw(GameTime gameTime)
103 {
104 GraphicsDevice.Clear(Color.White);
105
106 spriteBatch.Begin();
107
108 Renderer.Draw(spriteBatch);
109
110 spriteBatch.End();
111
112 base.Draw(gameTime);
113 }
114 }
115}